using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
using UnityX;

namespace UnityXEditor
{
    [CanEditMultipleObjects]
    [CustomEditor(typeof(ImageSector), true)]
    internal class ImageSectorEditor : GraphicEditor
    {
        private SerializedProperty m_Texture;
        private SerializedProperty m_VertCount;
        private SerializedProperty m_BorderShape;
        private SerializedProperty m_BeginAngle;
        private SerializedProperty m_EndAngle;

        protected override void OnEnable()
        {
            base.OnEnable();
            m_Texture = serializedObject.FindProperty("m_Texture");
            m_VertCount = serializedObject.FindProperty("m_VertCount");
            m_BorderShape = serializedObject.FindProperty("m_BorderShape");
            m_BeginAngle = serializedObject.FindProperty("m_BeginAngle");
            m_EndAngle = serializedObject.FindProperty("m_EndAngle");
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.PropertyField(m_Texture);
            AppearanceControlsGUI();
            RaycastControlsGUI();
            MaskableControlsGUI();
            EditorGUILayout.PropertyField(m_BeginAngle, new GUIContent("开始角度"));
            EditorGUILayout.PropertyField(m_EndAngle, new GUIContent("结束角度"));
            EditorGUILayout.PropertyField(m_BorderShape, new GUIContent("边框形状"));
            if (m_BorderShape.enumValueIndex == (int)ImageSector.BorderShape.Circle)
            {
                EditorGUILayout.PropertyField(m_VertCount, new GUIContent("顶点数量"));
            }
            serializedObject.ApplyModifiedProperties();
        }
    }
}